package com.cyf.utils.file;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class FileUtilC {

    /**
     * 按行读取文件
     * @param fileName
     * @return
     */
    public static List<String> readFileByLines(String fileName) {
        File file = new File(fileName);
        BufferedReader br=null;
        List<String> list=new ArrayList<>();
        try {
            br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
            String str="";
            while ((str=br.readLine())!=null){
                list.add(str);
            }
            br.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if(br!=null){
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return list;
    }
}
